module.exports = updateFoodController;
updateFoodController.$inject = [
    '$scope',
    '$location',
    //'$routeParams',
    'foodService',
    '$uibModal',
    '$uibModalInstance',
    'food',
    'refreshFood'
]
function updateFoodController($scope, $location, FoodSvc,$modal,$uibModalInstance,food,refreshFood){

    $scope.food = food;
    $scope.cancel = function(){
        $uibModalInstance.dismiss('cancel');
        console.log("modalewrwere  close !");
    }
    $scope.ok = function(){
        var foodForm = document.querySelector('#updateFoodForm');
        var formData = new FormData(foodForm);
        formData.append('_id', $scope.food._id);
        // for (var pair of formData.entries()) {
        //   console.log(pair[0] + ',,,,,,,' + pair[1]);
        // }
        FoodSvc.updateFood(formData,function(err,data){
            if(err){
                console.log("err")
            }else{
                $uibModalInstance.dismiss('cancel');
                refreshFood();
            }
        });
    }



}

